package com.dushibao.manage.user;

import com.dushibao.service.UserService;
import com.dushibao.service.impl.UserServiceImpl;
import com.dushibao.utils.Page;
import com.dushibao.view.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/user/list")
public class ListServlet extends HttpServlet {
    UserService userService = new UserServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String current = req.getParameter("current");
        String pageSize = req.getParameter("pageSize");
        String userName = req.getParameter("userName");

        Page page = new Page();
        page.setCurrent(Integer.parseInt(current==null?"1":current));
        page.setPageSize(Integer.parseInt(pageSize==null?"10":pageSize));

        Page iPage = userService.page(page,userName);

        Map<String,Object> maps = new HashMap<>();
        maps.put("iPage",iPage);
        maps.put("userName",userName);

        ModelAndView mv = new ModelAndView("user/list",maps);

        //ModelAndView mv = new ModelAndView(req,resp,"user/list");

    }
}
